include ../Makefile.config

CXXINCLUDES = ${INCLUDES} ${MPIINCLUDE}

FILEDIRS =\
 ${CURDIR}

CXX_COMPILE_FLAGS =\
 $(patsubst %,-I%,$(FILEDIRS))\
 ${CINCLUDES}

HEADERS=$(foreach dir, $(FILEDIRS) , $(wildcard $(dir)/*.hpp) $(wildcard $(dir)/*.h))


CFILES =\
 utilityBasicFunction.c

CPPFILES =\
 parameters.cpp\
 mpiWrapper.cpp\
 unapVector.cpp\
 utilityCommunicator.cpp\
 utilityCommunicationManager.cpp\
 utilityMpiWrapper.cpp\
 utilityInterfaces.cpp



CPPOBJS = ${CPPFILES:.cpp=.o}
COBJS = ${CFILES:.c=.o}
OBJS = ${CPPOBJS} ${COBJS}

SONAME = libUNAP_base-${LIB_SUFFIX}

##################################################################
# Targets
##################################################################

all: libUNAP_base${LIB_SUFFIX}

install: libUNAP_base${LIB_SUFFIX}

clean:
	rm -f *.o *.obj libUNAP*

distclean: clean

##################################################################
# Rules
##################################################################

libUNAP_base.a: ${OBJS}
	@echo  "Building $@ ... "
	${AR} $@ ${OBJS}
	${RANLIB} $@
	cp ${HEADERS} ${INSTALL_DIR}/include

libUNAP_base.so libUNAP_base.dylib: ${OBJS}
	@echo  "Building $@ ... "
	${BUILD_CC_SHARED} -o ${SONAME} ${OBJS} ${SHARED_SET_SONAME}${SONAME}
	ln -s -f ${SONAME} $@
	cp ${HEADERS} ${INSTALL_DIR}/include


